package models

import (
	"CMETO/utils"
	"time"
)

// 订单表
type Order struct {
	// 标识Id
	Id int `json:"id" gorm:"column:id;type:int;auto_increment;primary_key;"`
	// 订单编号
	OrderNumber string `json:"order_number" gorm:"column:order_number;type:varchar(13);"`
	// 商品Id
	GoodsId int `json:"goods_id" gorm:"column:goods_id;type:int;"`
	// 下单人
	CustomerId int `json:"customer_id" gorm:"column:customer_id;type:int;"`
	// 下单人手机号
	Phone string `json:"phone" gorm:"column:phone;type:varchar(18);"`
	// 金额
	Amount string `json:"amount" gorm:"column:amount;type:varchar(50);"`
	// 订单备注
	Remark string `json:"remark" gorm:"column:remark;type:varchar(120);"`
	// 状态 1：已支付，2：已完成
	Status int `json:"status" gorm:"column:status;type:int;"`
	// 创建时间
	CreateTime string `json:"create_time" gorm:"column:create_time;type:varchar(30);"`
	// 是否删除
	IsDelete int `json:"is_delete" gorm:"column:is_delete;type:int;"`
}
type OrderFormat struct {
	*Order
	Customer  string `json:"customer"`
	GoodsName string `json:"goodsName"`
}

// 插入一批订单数据
func InsertMockOrder() {
	DB.Model(&Order{}).Create([]Order{
		{Id: 0, OrderNumber: "202010100001", Phone: "14770823957", Amount: "100", GoodsId: 1, CustomerId: 10, Remark: "已买", Status: 1, CreateTime: utils.TimeFormatter(time.Now()), IsDelete: 0},
	})
}
